package pub.guoxin.oops.manager.handler;

import com.google.common.collect.ImmutableMap;
import pub.guoxin.oops.model.Boundary;
import pub.guoxin.oops.utils.JsonUtils;

import java.util.Map;

/**
 * Create by guoxin on 2018/3/30
 */
public class AlarmFieldNameConstants {

    public static final String AlarmInfoHandler = "AlarmInfoHandler";

    public static final String COMMUNICATION_BATTERY = "communicationBattery";
    public static final String DEVICE_BATTERY = "deviceBattery";
    public static final String NORM_MOMENT_FLOW = "normMomentFlow";
    public static final String WORK_MOMENT_FLOW = "workMomentFlow";
    public static final String WORK_PRESSURE = "workPressure";
    public static final String WORK_TEMPERATURE = "workTemperature";

    /**
     * @param key 字段名称
     * @param value 默认值
     */
    public static final Map<String, Boundary> FIELD_NAME_DEFAULT_VALUE;

    public static final Map<String, String> FIELD_NAME_MAP;

    static {
        FIELD_NAME_DEFAULT_VALUE = ImmutableMap.<String, Boundary>builder()
                /*
                 通讯模块电量默认值，小于设定值报警(在0~100%可设)
                 */
                .put(COMMUNICATION_BATTERY, new Boundary(25.0, null))
                /*
                仪表电量默认值，小于设定值报警(在0~100%可设)
                 */
                .put(DEVICE_BATTERY, new Boundary(25.0, null))
                /*
                标况瞬时流量，错误报警上限报报警，下上限报报警(在0.0m3/h~100000m3/h可设，但上限>下限）
                 */
                .put(NORM_MOMENT_FLOW, new Boundary(0.0, 100000))
                /*
                工况瞬时流量，错误报警上限报报警，下上限报报警(在0.0m3/h~100000m3/h可设，但上限>下限）
                 */
                .put(WORK_MOMENT_FLOW, new Boundary(0.0, 100000))
                /*
                工况温度，错误报警上限报报警，下上限报报警(在---60.0℃~150℃可设，但上限>下限）
                 */
                .put(WORK_PRESSURE, new Boundary(60, 150))
                /*
                工况压力，错误报警上限报报警，上限报报警(在0.0Kpa~10000Kpa可设，但上限>下限）
                 */
                .put(WORK_TEMPERATURE, new Boundary(0.0, 10000))
                .build();
        ;
        FIELD_NAME_MAP = ImmutableMap.<String, String>builder()
                .put(COMMUNICATION_BATTERY, "通讯模块电量")
                .put(DEVICE_BATTERY, "仪表电量")
                .put(NORM_MOMENT_FLOW, "标况瞬时流量")
                .put(WORK_MOMENT_FLOW, "工况瞬时流量")
                .put(WORK_PRESSURE, "工况温度")
                .put(WORK_TEMPERATURE, "工况压力")
                .build();
    }

    public static void main(String[] args) {
        System.out.println(JsonUtils.obj2json(FIELD_NAME_MAP));
    }
}
